package com.campus.mapper;

import com.campus.annotation.AutoFill;
import com.campus.enumeration.OperationType;
import com.campus.pojo.dto.StudyRoomPageQueryDTO;
import com.campus.pojo.entity.StudyRoom;
import com.campus.pojo.vo.StudyRoomVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;


@Mapper
public interface StudyRoomMapper {

    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into studyroom(name, location, status, create_time, update_time) values(#{name}, #{location}, #{status}, #{createTime}, #{updateTime})")
    void insert(StudyRoom studyRoom);


    @Select("select * from studyroom where name = #{name}")
    StudyRoom getByName(String name);

    @Select("select * from studyroom where id = #{id}")
    StudyRoom getById(Long id);

    void deleteByIds(List<Long> ids);

    Page<StudyRoomVO> pageQuery(StudyRoomPageQueryDTO studyRoomPageQueryDTO);

    //写成动态sql 以便更新状态和更新信息复用
    @AutoFill(value = OperationType.UPDATE)
    void update(StudyRoom studyRoom);
}
